﻿package mortal.game.view.closedBetaGiftBagNew.panel
{
    import __AS3__.vec.*;
    import com.gengine.core.frame.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.data.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.view.closedBetaGiftBagNew.cellRender.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class ClosedBetaTimingGiftPanel extends ClosedBetaBasePanel
    {
        private var _timeText:BitmapNumberText;
        private var _timer:SecTimer;
        private var _btnList:GTileList;

        public function ClosedBetaTimingGiftPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildren();
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.closedBetaGiftBagNewBg2, 5, 30, this));
            this._btnList = UIFactory.tileList(264 - 48, 402 - 200, 604, 400, this);
            this._btnList.setStyle("cellRenderer", ClosedBetaTimingGiftCellRender);
            this._btnList.columnWidth = 302;
            this._btnList.rowHeight = 200;
            this._btnList.direction = GBoxDirection.VERTICAL;
            this._btnList.dataProvider = this.getTimingGiftDataProvider();
            this._btnList.drawNow();
            this._timeText = UIFactory.bitmapNumberText(486, 162, "DoubleRewardTimerNum.png", 18.18, 27, 0, this, 10, BitmapNumberText.Mid);
            this._timeText.customCharIndex = {0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, ::10};
            this._timeText.text = "00:00:00";
            this._timer = new SecTimer();
            this._timer.addListener(TimerType.ENTERFRAME, this.updateTimeShow);
            this._timer.start();
            return;
        }// end function

        private function getTimingGiftDataProvider() : DataProvider
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.closedBetaTimingGift.timingGiftVec;
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_1.addItem(_loc_2[_loc_3]);
                _loc_3++;
            }
            return _loc_1;
        }// end function

        override public function refresh() : void
        {
            if (!this._btnList)
            {
                return;
            }
            this._btnList.dataProvider = this.getTimingGiftDataProvider();
            this._btnList.drawNow();
            return;
        }// end function

        private function updateTimeShow(param1:Object) : void
        {
            if (isDisposed)
            {
                this._timer.stop();
                return;
            }
            var _loc_2:* = ClockManager.instance.nowDate;
            var _loc_3:* = _loc_2.hours.toString();
            if (_loc_3.length < 2)
            {
                _loc_3 = "0" + _loc_3;
            }
            var _loc_4:* = _loc_2.minutes.toString();
            if (_loc_4.length < 2)
            {
                _loc_4 = "0" + _loc_4;
            }
            var _loc_5:* = _loc_2.seconds.toString();
            if (_loc_5.length < 2)
            {
                _loc_5 = "0" + _loc_5;
            }
            var _loc_6:* = _loc_3 + ":" + _loc_4 + ":" + _loc_5;
            this._timeText.text = _loc_6.toString();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._timer.stop();
            this._timeText.dispose(param1);
            this._timeText = null;
            return;
        }// end function

    }
}
